﻿@model IEnumerable<SimplCommerce.Module.Core.Areas.Core.ViewModels.UserAddressListItem>
@{
    ViewData["Title"] = Localizer["Address book"];
}

<div class="row">
    <div class="col-md-3">
        <partial name="_AccountMenu" />
    </div>
    <div class="col-md-9">
        <h2>@Localizer["Address Book"]</h2>
        <hr />
        @foreach (var address in Model)
        {
            <div>
                <strong>@address.ContactName </strong><br />
                @address.AddressLine1 <br />
                @if(address.DisplayDistrict){
                    <text>@address.DistrictName,</text>
                }
                @address.StateOrProvinceName <br />
                Phone: @address.Phone
            </div>
            <div>
                @if (address.IsDefaultShippingAddress)
                {
                    <span class="label label-primary">@Localizer["Default shipping address"]</span>
                }
                else
                {
                    <form method="post" style="display: inline" asp-area="Core" asp-controller="UserAddress" asp-action="SetAsDefault" asp-route-id="@address.UserAddressId">
                        <button type="submit" class="btn btn-link" style="padding: 0">@Localizer["Set as default shipping address"]</button>
                    </form>
                    <span> | </span>
                }
                <a href="~/user/address/edit/@address.UserAddressId">@Localizer["Edit"]</a><span> | </span>
                <form method="post" style="display: inline" asp-area="Core" asp-controller="UserAddress" asp-action="Delete" asp-route-id="@address.UserAddressId">
                    <button type="submit" class="btn btn-link" style="padding: 0">@Localizer["Delete"]</button>
                </form>
            </div>
            <hr />
        }

        <div class="text-right"><a class="btn btn-primary" href="~/user/address/create">@Localizer["Add Address"]</a></div>
    </div>
</div>
